<template>
  <div>
    <h3>待审核{{ count }}条</h3>
    <table>
      <tr>
        <td>审核名字</td>
        <td>操作</td>
      </tr>
      <tr v-for="i in list" :key="i">
        <td>{{ i.name }}</td>
        <td>
          <van-button @click="get_one(i.id)">查看详情</van-button>
        </td>
      </tr>
    </table>
    <van-popup v-model:show="shows" style="width: 600px;height: 300px;font-size: 15px;padding: 10px">
      <p v-for="i in my_audi_task" :key="i">
      {{i.username}}--{{change_stade(i.is_agree)}}--{{i.reason}}--{{i.add_time}}
      </p>

      <table >
        <tr>
          <td>详细</td>
          <td>请假理由</td>
          <td>请假类型</td>
          <td>文件</td>
          <td>开始时间</td>
          <td>结束时间</td>
          <td>状态</td>
          <td>名称</td>
        </tr>
        <tr v-for="(i,v) in param" :key="v">
          <td>{{i.姓名}}</td>
          <td>{{i.请假理由}}</td>
          <td>{{i.请假类型}}</td>
          <td>{{i.文件}}</td>
          <td>{{i.开始时间}}</td>
          <td>{{i.结束时间}}</td>
          <td>{{change_k(dict.state)}}</td>
          <td>{{dict.title}}</td>
        </tr>
      </table>
      <div>
       是否同意: <van-radio-group v-model="redio" direction="horizontal"  position="bottom">
          <van-radio name="1">是</van-radio>
          <van-radio name="2">否</van-radio>
        </van-radio-group>
        <van-field label="原因:" placeholder="请输入:" v-model="reason"></van-field>
        <van-button @click="change_status">确认</van-button>
      </div>
    </van-popup>
  </div>
</template>

<script>
export default {
  name: "my_task_dai",
  data() {
    return {
      list: [],
      count: '',
      shows: false,
      active:0,
      shenlist:[],
      dict:[],
      statelist:{1:'待审核',2:'审核中',3:'审核通过',4:'审核失败'},
      stade:{1:'同意',2:'没同意'},
      param:[],
      my_audi_task:[],
      name:localStorage.getItem('name'),
      userid:localStorage.getItem('userid'),
      redio:'',
      taskid:'',
      reason:'',
    }
  },
  methods: {
    change_stade(id){
      return this.stade[id]
    },
    change_status(){
      this.myaxios('http://localhost:5000/my_task_one', 'post', {'taskid': this.taskid,'userid':this.userid,'username':this.name,'is_agree':this.redio,'reason':this.reason})
          .then(res => {
            console.log(res)
          })
    },

    change_k(id){
      return this.statelist[id]
    },
    get_one(id) {
      console.log(id)

      this.shows = true
      this.taskid=id
      this.myaxios('http://localhost:5000/my_task_one', 'get', {'id': id})
          .then(res => {
            console.log(res)
            this.dict=res.data.list
            this.param=res.data.param
            this.my_audi_task=res.data.my_audi_task
          })

    },
    get_task() {
      this.myaxios('http://localhost:5000/my_task', 'get', {'id': localStorage.getItem('userid')})
          .then(res => {
            console.log(res)
            this.count = res.data.count
            this.list = res.data.dict

          })
    }
  },
  mounted() {
    this.get_task()
  }
}
</script>

<style scoped>

</style>
